package org.ewaf.framework.mail;

import java.util.Date;

import javax.mail.internet.ContentType;
import javax.mail.internet.InternetAddress;

import org.ewaf.framework.mail.content.AttachmentContent;
import org.ewaf.framework.mail.content.MixedContent;
import org.ewaf.framework.mail.content.StringDataSource;
import org.ewaf.framework.mail.content.TextContent;


public class TestMailSender {

	public static void main(String[] args) throws Exception {
		MailSender sender = new MailSender();
		sender.setHost("smtp.mail.yahoo.com.cn");
		sender.setUsername("alisofttest001");
		sender.setPassword("hello123");
		sender.setFromAddress("alisofttest001@yahoo.com.cn");
		
		Mail mail = new Mail();
		mail.setCharset("UTF-8");
		mail.setSubject("标题");
		mail.setGmtSent(new Date());
		mail.setToAddress(new InternetAddress[] { new InternetAddress("jacky.chenb@alibaba-inc.com") });

		MixedContent mc = new MixedContent();
		mc.addContent(new TextContent("正文", new ContentType("text/plain")));
		mc.addContent(new AttachmentContent("附件名称", 
				new StringDataSource("<B>附件内容</B>", "text/html", "GBK")));
		mail.setContent(mc);
		
		sender.send(mail);
	}

}
